class NotifiesController < BaseController 

  def index
    @school_message_news = News.limit(10)
    @hot_sptitles = Sptitle.all.order("ordinal desc").order("created_at desc").limit(2)
    @pic_say_huali_news = News.index_news.where(category_id: NewsHelper::TSHL_CATEGORY).order("created_at desc").limit(5)
    @notifies = Notify.where(:check => 2).page params[:page]
    @intro_news = News.index_news.where(is_important_news: 1).where("pubtime>=?",30.days.ago).order("ordinal desc").order("hits desc").limit(10)
  end

  def show
    @notify = Notify.where({id: params[:id]}).first
    @notify.update_attributes(hits: 1) if @notify.hits.blank?
    sql = "update notifies set hits = hits+1 where id=#{@notify.id}"
     ActiveRecord::Base.connection.execute(sql)
     
     unless @notify.contribution_units_id.nil?
        @notify.contribution_units = Department.find(@notify.contribution_units_id).name
     else
       @notify.contribution_units = @notify.fromwhere
     end
       
   
     
     
  end

end
